<template>
	<div class="code">
		<img :src="acstk" class="img"  mode="widthFix"/>
		 <button class="weui-btn" type="primary" @click="savepic()">保存图片</button>
	</div>
</template>

<script>
	import { mapGetters, mapMutations } from 'vuex'
	import botbar from '../../components/botbar'
	import { requests } from "../../../static/js/network"
	
	export default{
		data(){
			return{
				acstk:'',
			}
		},
		onLoad(){
			let self = this
				requests({
					url: 'https://tp5.blver.cn/api/wechat/getXQRCode',
					method: 'POST',
					header: {
						'content-type': 'application/json',
						'content-type': 'application/x-www-form-urlencoded' // 默认值
					},
					data: {
					
						session3rd: wx.getStorageSync('userinfo').session3rd,
						
					},
					success: function(res) {
					console.log(res)
						if(res.data.status == 'error') {
							wx.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
							return
						}
						self.acstk=res.data.data

					
						//self.content=self.classlist[0].goods_content.replace(/"\/static/g, '"https://tp5.blver.cn/static').replace(/"\/static/g, '"https://tp5.blver.cn/static').replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
					}
				})
		},
		methods:{
			
			savepic(){
					let self = this
				wx.downloadFile({
				  url: self.acstk, //仅为示例，并非真实的资源
				  success: function(res) {
				    // 只要服务器有响应数据，就会把响应内容写入文件并进入 success 回调，业务需要自行判断是否下载到了想要的内容
				    if (res.statusCode === 200) {
				        console.log(res)
				        
				        wx.saveImageToPhotosAlbum({
							filePath: res.tempFilePath, //仅为示例，并非真实的资源
							success: function(res) {
		
								// 只要服务器有响应数据，就会把响应内容写入文件并进入 success 回调，业务需要自行判断是否下载到了想要的内容
		
								console.log(res)
		
		
							}
						})
				        
				        
				        
				    }
				  }
				})
			}
		}
	}
</script>

<style scoped>
	.code{text-align: center;}
	.img{width: 95%;}
	.weui-btn{width: 95%;}
</style>